package com.linglingC.utils;

import java.math.BigDecimal;
import java.math.BigInteger;

import static com.linglingC.utils.CycleValue.*;


public class ChargeUtil {
    public  static double caculate(String cycle, int day, BigDecimal charge){
        int price=charge.intValue();
        if(cycle.equals("天")){
            return day/CYCLE_DAY*price;
        }
        if(cycle.equals("周")){
            return (day%CYCLE_WEEK)>0?(day/CYCLE_WEEK+1)*price:day/CYCLE_WEEK*price;
        }
        if(cycle.equals("月")){
            return (day%CYCLE_MOOTH)>0?(day/CYCLE_MOOTH+1)*price:day/CYCLE_MOOTH*price;
        }
        if(cycle.equals("年")){
            return (day%CYCLE_YEAR)>0?(day/CYCLE_YEAR+1)*price:day/CYCLE_YEAR*price;
        }
        return 0;
    }
}
